import {
  reqCategroyList,
  reqBannerList,
  reqFloorList
} from "@/api"

const state = {
  categoryList:[],
  bannerList:[],
  floorList: []
};
const mutations={
  GETCATEGORYLIST(state,data){
    state.categoryList = data;
  },
  GETBANNERLIST(state,data){
    state.bannerList = data;
  },
  GETFLOORLIST(state,data){
    state.floorList = data;
  }
};
const actions={
  // 派发获取三级列表action（指令从App.vue发出）
  async getcategoryList({commit}){
    let result=await reqCategroyList();
    if(result.code==200){
      commit("GETCATEGORYLIST",result.data)
    }
  },
  // 派发轮播图action（指令从ListConntainer组件发出）
  async getbannerList({commit}){
    let result=await reqBannerList();
    if(result.code==200){
      commit("GETBANNERLIST",result.data)
    }
  },
  // 派发floor action（指令从Home组件发出）
  async getFloorList({commit}){
    let result = await reqFloorList();
    if(result.code==200){
      commit("GETFLOORLIST",result.data)
    }
  }
};
const getters={};

export default {
  state,
  mutations,
  actions,
  getters
}